<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试页面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            min-height: 100vh;
        }
        
        .container {
            max-width: 500px;
            margin: 0 auto;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            padding: 20px;
            text-align: center;
        }
        
        h1 {
            margin-bottom: 20px;
        }
        
        .button {
            background: #ff6b6b;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            margin: 10px;
            cursor: pointer;
            font-size: 16px;
        }
        
        .status {
            margin: 20px 0;
            padding: 10px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🎮 测试页面</h1>
        
        <div class="status">
            <p>这是一个测试 HTML 页面</p>
            <p>当前时间: <span id="time"></span></p>
        </div>
        
        <button class="button" onclick="sendMessage()">发送消息到 uni-app</button>
        <button class="button" onclick="showAlert()">显示弹窗</button>
        
        <div id="messageArea" class="status">
            <p>等待消息...</p>
        </div>
    </div>

    <script>
        // 更新时间
        function updateTime() {
            document.getElementById('time').textContent = new Date().toLocaleString('zh-CN');
        }
        setInterval(updateTime, 1000);
        updateTime();
        
        // 发送消息到 uni-app
        function sendMessage() {
            if (typeof uni !== 'undefined') {
                uni.postMessage({
                    data: {
                        action: 'test',
                        message: 'Hello from test page!',
                        time: new Date().toISOString()
                    }
                });
                showMessage('消息已发送');
            } else {
                showMessage('不在 uni-app 环境中');
            }
        }
        
        // 显示弹窗
        function showAlert() {
            alert('这是来自 HTML 的弹窗！');
        }
        
        // 显示消息
        function showMessage(text) {
            document.getElementById('messageArea').innerHTML = `<p>${text}</p>`;
        }
        
        // 接收来自 uni-app 的消息
        function receiveMessage(data) {
            console.log('收到消息:', data);
            showMessage(`收到: ${JSON.stringify(data)}`);
        }
        
        // 页面加载完成
        document.addEventListener('DOMContentLoaded', function() {
            console.log('测试页面加载完成');
            showMessage('页面加载完成');
        });
    </script>
</body>
</html> 